﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://wubiyu.cnblogs.com">
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <link href="../../Theme/DomExtGray/gray.css" rel="Stylesheet" type="text/css" />
    <link href="PageModel.css" rel="Stylesheet" type="text/css" />
    <script type="text/javascript" src="../../domExt.js"></script>
    <style type="text/css">
        .style1
        {
            width: 82px;
        }
        .style2
        {
            height: 20px;
            width: 177px;
        }
    </style>
</head>
<body>
    <h:layout borderwidth="10,10,10,10" id="main">
        <h:head borderwidth="0,0,0,0">
            <h:grid layoutid="main" id="grid1" rowheight="30" ismultiselect="false" isunselectedinonclick="false">
                <h:gridcolumn width="30" isdraging="false" >
                    <h:headertemplet>
                        <input type="checkbox" style="margin-top: 5px;" id="grid1_HeaderChk" />
                    </h:headertemplet>
                    <h:datatemplete>
                        <input type="checkbox" style="margin-top: 3px;" id="gird1_rowChk{=CurrentIndex}" />
                    </h:datatemplete>
                </h:gridcolumn>
                <h:gridcolumn width="55" isdraging="false">
                    <h:headertemplet>
                         编号
                    </h:headertemplet>
                    <h:datatemplete>
                            {=no}
                    </h:datatemplete>
                </h:gridcolumn>
                <h:gridcolumn>
                    <h:headertemplet>
                        自动列
                    </h:headertemplet>
                    <h:datatemplete>
                        {=name}
                    </h:datatemplete>
                </h:gridcolumn>
                <h:gridcolumn width="*" >
                    <h:headertemplet>
                        肉容
                    </h:headertemplet>
                    <h:datatemplete>
                         {=name}
                    </h:datatemplete>
                </h:gridcolumn>
                <h:gridcolumn width="400">
                    <h:headertemplet>
                            积分
                    </h:headertemplet>
                    <h:datatemplete>
                        ddddddddd<h:btn>测试</h:btn>
                    </h:datatemplete>
                </h:gridcolumn>
            </h:grid>
        </h:head>
        <h:bottom borderwidth="0,0,0,0" hposition="0,0,*,30">
            <h:btn id="updateRowbtn">更新一行</h:btn>&nbsp;
<h:btn id="additembtn">AddItem</h:btn>&nbsp;
<h:btn id="deleteItembtn">删除一行</h:btn>
<h:btn id="hiddencolumebtn">隐藏列</h:btn>
<h:btn id="showcolumebtn">显示列</h:btn>
<div id="Message">
</div>
        </h:bottom>
    </h:layout>
    <script type="text/javascript">
        var data = new Array();
        for (var i = 0; i < 110; i++) {
            data[i] = {};
            data[i].no = i;
            data[i].name = "文件编辑文件编辑文件编辑文件编辑文件编辑文件编辑文件编辑文件编辑文件编辑" + i;
        }

        _h.ready(function () {
            var grid1 = _g("#grid1");
            grid1.OnItemClick = function (grid, dom, index) {
                var datas = _h.Grid.GetSelect(grid1);
                //alert(datas.length);

            };
            grid1.OnRowBinded = function (grid, dom, i) {
                var Items = grid.Items;
            };
            grid1.SelectChangeHandler = function (grid, index) {
                var gird1_rowChk = _g("#gird1_rowChk" + index);
                gird1_rowChk.checked = grid.Items[index].Selected;
            };
            grid1.BindedHandler = function () {
                _h.Grid.SelectedHeader(grid1, 1);
                var grid1_HeaderChk = _g("#grid1_HeaderChk");
                _h.addEvent(grid1_HeaderChk, "click", function () {
                    grid1.ismultiselect = "true";
                    if (grid1_HeaderChk.checked)
                        _h.Grid.SelectAll(grid1);
                    else
                        _h.Grid.UnSelectAll(grid1);
                    grid1.ismultiselect = "false";
                });
            };
            _h.Grid.Bind(grid1, data, true);
            var updateRowbtn = _g("#updateRowbtn");
            //更新一行 Btn_Click
            _h.addEvent(updateRowbtn, "click", function () {
                grid1.Data[8].name = "更新一行";
                _h.Grid.UpdateItem(grid1, 8);
            });
            //添加一行 Btn_Click
            _h.addEvent(_g("#additembtn"), "click", function () {
                var i = _h.Grid.AddItem(grid1, { no: 100, name: "wubiyu" });
                //_h.Grid.Bind(grid1, grid1.Data, true);
            });
            //删除一行 Btn_Click
            _h.addEvent(_g("#deleteItembtn"), "click", function () {
                alert(_h.Grid.DeleteItem(grid1, 8));
                //_h.Grid.Bind(grid1, grid1.Data, true);
            });
            //隐藏列
            _h.addEvent(_g("#hiddencolumebtn"), "click", function () {
                grid1.columns[3].isshow = "false";
                grid1.columns[4].isshow = "false";
                _h.Grid.ShowColumns(grid1);
            });
            //显示列
            _h.addEvent(_g("#showcolumebtn"), "click", function () {
                grid1.columns[3].isshow = "true";
                grid1.columns[4].isshow = "true";
                _h.Grid.ShowColumns(grid1);
            });

        });
    
    </script>
</body>
</html>

